package com.inspur.encache.startup;

import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

@EnableCaching  // 这个必须加
public class CachingConfig {

    /**
     * 配置cacheManager： ConcurrentMapCache
     * @return
     */
    @Bean
    public CacheManager cacheManager() {
        SimpleCacheManager cacheManager = new SimpleCacheManager();
        cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("globalCache"),new ConcurrentMapCache("globalCache2")));
        return cacheManager;
    }
}
